home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 18 April 1997
- //
- //
-
-
- proc concatArray (string $res[], string $in[])
- {
- for ($i in $in)
- $res[size($res)] = $i;
- }
-
- proc string[] extractShapesWithPath (string $in[], string $type)
- {
- string $res[];
- for ($i in $in) {
- // first test that the visibility exists for the object
-
- string $vis_exists[1]=`listAttr -s -st visibility $i`;
- if (size($vis_exists) == 0) continue;
- // then check if the object is visible (or it will mess up the
- // unite/separate implementation)
- int $vis=`getAttr ($i + ".visibility")`;
- if ($vis != 1) continue;
-
- // now check if the object is not an intermediate object...
- $vis_exists=`listAttr -s -st intermediateObject $i`;
- if (size($vis_exists) != 0) {
- $vis=`getAttr ($i + ".intermediateObject")`;
- if ($vis != 0) continue;
- }
-
- if ($type == `nodeType $i`) $res[size($res)]=$i;
- else {
- // this means that if a top level object is selected
- // its children are selected too...
- string $curlevel[]=`listRelatives -c -pa $i`;
- if (size($curlevel) != 0)
- concatArray $res `extractShapesWithPath $curlevel $type`;
- }
- }
- return $res;
- }
-
- global proc string[] polyCheckSelection (string $fun, string $funtype)
- {
- // first set up various attributes & selection constraints
- // to allow the action to show up clearly
-
- // extract command name
- string $tmp[];
- tokenize($fun, $tmp);
- $fun = $tmp[0];
-
- string $sres[];
- int $res=0;
- int $isInstalled=0;
-
- if ($funtype == "o") {
- // for function that work on objects, we need to do the job ourselves...
- string $sel[];
- polyInstallAction -uc -ud; // remove any pending constraint.
-
- // unite, separate and boolean ops want all the shapes,
- // but with their correct path information.
- // Note bool ops need to take the lead object separately...
- $sel=`ls -sl`;
- string $hllist[]=`ls -hl`;
- if (size($hllist) != 0)
- concatArray $sel $hllist;
- $sres=`extractShapesWithPath $sel "mesh"`;
- $res=size($sres);
-
- clear $sel;
- if ($res == 0)
- warning ($fun + " works only on polygonal objects.");
- } else {
- if (`optionVar -q polyAutoConvertAction`)
- {
- $sres = `polyInstallAction -cs $fun`;
- if (! `optionVar -q polyAutoInstallAction`)
- polyInstallAction; // Remove settings
- }
- else if (`optionVar -q polyAutoInstallAction`)
- $sres = `polyInstallAction $fun`;
- else
- {
- polyInstallAction; // Remove prev settings
- $sres = `ls -sl`;
- }
- // usually polyInstallAction of a poly command provides
- // the list of all matching items
- $res = size($sres);
- $isInstalled = `polyInstallAction -q -cn` != "";
- }
-
- global string $polyLastTool;
- global string $gSelect;
-
- if ($res == 0) {
- if (! `optionVar -q polyAutoInstallAction`) {
- if ($isInstalled)
- polyInstallAction -uc $fun;
- // no last tool to store
- $polyLastTool="";
- } else {
- // *** should show in setSelectMode that the mode is for $fun
- // *** should set a script job to remove the sel. constraints.
- // when the selectMode or selectType is changed.
- $polyLastTool=`currentCtx`;
- setToolTo $gSelect;
- }
- } else {
- if (`optionVar -q polyAutoInstallAction` &&
- (`getModifiers` % 2) == 1) { // shift is down
- warning ("Setup for " + $fun);
- // setup for action: don't do the action, just prepare for it...
- clear $sres;
- // *** should show in setSelectMode that the mode is for $fun
- // *** should set a script job to remove the sel. constraints.
- // when the selectMode or selectType is changed.
- } else {
- // uninstall selection constraints
- if ($isInstalled)
- polyInstallAction -uc $fun;
- }
- // store last tool
- $polyLastTool=`currentCtx`;
- setToolTo $gSelect;
- }
- // return array of objs to process
- return $sres;
- }
-